package jflowmap.model.ontology.calculation.expression;

import java.util.Map;

import jflowmap.model.ontology.calculation.Variable;

public class VariableExpression implements Expression {
	
	private final String identifier;
	
	public VariableExpression (String variable) {
		this.identifier = variable;
	}

	@Override
	public double value(Map<String, Variable> variables) throws VariableMissingException {
		if (!variables.containsKey(identifier)) {
			throw new VariableMissingException();
		} else {
			return variables.get(identifier).getValue();
		}		
	}
}
